//
//  DDNFVC.swift
//  SinaMicroBlog
//
//  Created by dqw on 15/7/31.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

private let reuseIdentifier = "Cell"
let imagCount = 4

class DDNFVC: UICollectionViewController {

    let flowLayout = DDFlowLayout()
    
     override init(collectionViewLayout layout: UICollectionViewLayout) {
        super.init(collectionViewLayout: flowLayout)
        
        
    }

     required init?(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.collectionView!.registerClass(DDNFCell.self, forCellWithReuseIdentifier: reuseIdentifier)

        // Do any additional setup after loading the view.
    }

    // MARK: UICollectionViewDataSource

    override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return imagCount
    }


    override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of items
        return 0
    }

    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath)
    
        // Configure the cell
    
        return cell
    }
}

private class DDNFCell: UICollectionViewCell {
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    private func loadAndLayouSubviews() {

}

    lazy private var backImg = UIImageView()
    private var startBtn:UIButton {
        let btn = UIButton()
        btn.setTitle("开始体验", forState: UIControlState.Normal)
        btn.setImage(UIImage(named: "new_feature_finish_button"), forState: UIControlState.Normal)
        btn.setImage(UIImage(named: "new_feature_finish_button_highlighted"), forState: UIControlState.Highlighted)
        btn.sizeToFit()
        btn.addTarget(self, action: "startBtnClick()", forControlEvents: UIControlEvents.TouchUpInside)
        return btn
    }

    private func startBtnClick() {
        // TODO: 通知注册
    }
}


 class DDFlowLayout: UICollectionViewFlowLayout {
    
    override internal func prepareLayout() {
        super.prepareLayout()
        itemSize = (collectionView?.bounds.size)!
        minimumInteritemSpacing = 0
        minimumLineSpacing = 0
        scrollDirection = UICollectionViewScrollDirection.Horizontal
        
        collectionView?.pagingEnabled = true
        collectionView?.showsHorizontalScrollIndicator = false
        collectionView?.bounces = false
    }
}

